package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.OrderService;
import cn.bytecollege.common.constant.Resource;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author NJK
 */
@WebServlet(name = "OrderDeleteController",value = "/admin/orderDelete")
public class OrderDeleteController extends HttpServlet {
    private OrderService orderService =null;
    public OrderDeleteController(){
        orderService = new OrderService();
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //接受参数
        String orderNumber = req.getParameter("orderNumber");
        //执行删除语句
        orderService.deleteByOrderNumber(orderNumber);
        //请求转发回到订单列表
        req.getRequestDispatcher(req.getContextPath()+"/admin/orderList").forward(req,resp);
    }
}
